package logic

import (
	"Serve/VideoSrv"
	"Serve/global/model"
	"Serve/internal/svc"
	"context"

	"github.com/zeromicro/go-zero/core/logx"
)

type VideoPushLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewVideoPushLogic(ctx context.Context, svcCtx *svc.ServiceContext) *VideoPushLogic {
	return &VideoPushLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *VideoPushLogic) VideoPush(in *VideoSrv.VideoPushRequest) (*VideoSrv.VideoPushResponse, error) {
	// todo: add your logic here and delete this line
	var video = model.Video{
		Title:    in.Title,
		ClassId:  int(in.Class),
		Des:      in.Des,
		Tag:      in.Tag,
		VideoUrl: in.VideoUrl,
		ImageUrl: in.ImageUrl,
		UserId:   int(in.UserId),
	}
	if err := model.DB.Create(&video).Error; err != nil {
		return nil, err
	}
	return &VideoSrv.VideoPushResponse{}, nil
}
